using System.Collections.Generic;
using System.Diagnostics;
using Baula.TextGen.ActiveTemplating.Tokenizer.Tokens;

namespace Baula.TextGen.ActiveTemplating.Tokenizer
{
    public class TokensDumper 
    {
        public void Dump(IEnumerable<IToken> tokens)
        {
            Debug.WriteLine("=== Begin Tokens Dump");
            foreach (var token in tokens)
            {
                var tokenInfo = token.ToString().Replace("\r", "\\r").Replace("\n", "\\n");
                string leftDelim = string.Empty, rightDelim = string.Empty;
                if (token is LiteralToken)
                {
                    leftDelim = "-->";
                    rightDelim = "<--";
                }
                Debug.WriteLine("- {0}:\t{2}{1}{3}", token.GetType().Name, tokenInfo, leftDelim, rightDelim);
            }
            Debug.WriteLine("=== End Tokens Dump");
        }
    }
}